<template>
	<view class="private-key">
		<view class="icon">
			<image src="../../../static/icon/warning.png" mode="widthFix"></image>
		</view>
		<view class="icon-text">
			<view class="text-dark">认真抄写 安全保管 切勿泄露自己的私钥</view>
			<view class="text-dark">系统不保管用户私钥，遗失无法找回</view>
		</view>
		<view class="box bg-box">
			<view class="header">
				<view class="box-title text-highlight">地址</view>
				<view class="box-icon" @click="copyAddress()">
					<view class="iconfont icon-fuzhi"></view>
				</view>
			</view>
			<view class="content">{{address}}</view>
		</view>
		<view class="box bg-box">
			<view class="header">
				<view class="box-title text-highlight">私钥</view>
				<view class="box-icon" @click="copyPrivateKey()">
					<view class="iconfont icon-fuzhi"></view>
				</view>
			</view>
			<view class="content">{{privateKey}}</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				address: "",
				privateKey: "",
			}
		},
		onLoad(e) {
			let user = uni.getStorageSync("user")
			this.address = user.wallet_address;
			this.privateKey = e.privateKey;
		},
		methods: {
			copyPrivateKey() {
				let that = this;
				uni.setClipboardData({
					data: that.privateKey,
					success: () => {
						// 成功处理
						// #ifdef MP-ALIPAY || MP-BAIDU || MP-TOUTIAO
						uni.showToast({
							title: '已复制私钥',
							icon: "success",
							mask: !1
						})
						// #endif
					},
					fail: () => {
						// 失败处理
						// #ifdef MP-ALIPAY || MP-BAIDU || MP-TOUTIAO
						uni.showToast({
							title: '复制私钥失败',
							icon: "none",
							mask: !1
						})
						// #endif
					}
				});
			},
			copyAddress() {
				let that = this;
				uni.setClipboardData({
					data: that.address,
					success: () => {
						// 成功处理
						// #ifdef MP-ALIPAY || MP-BAIDU || MP-TOUTIAO
						uni.showToast({
							title: '已复制地址',
							icon: "success",
							mask: !1
						})
						// #endif
					},
					fail: () => {
						// 失败处理
						// #ifdef MP-ALIPAY || MP-BAIDU || MP-TOUTIAO
						uni.showToast({
							title: '复制地址失败',
							icon: "none",
							mask: !1
						})
						// #endif
					}
				});
			},
		}
	}
</script>

<style lang="scss">
	page {
		background-image: url(../../../static/background/layout_bg.png);
		background-size: cover;
	}

	view {
		display: flex;
		flex-direction: column;
		box-sizing: border-box;
	}

	.private-key {
		padding-top: 100px;

		.icon {
			text-align: center;

			image {
				width: 100px;
				margin: 0 auto;
			}
		}

		.icon-text {
			padding-top: 30px;

			view {
				font-size: 14px;
				text-align: center;
			}
		}
	}

	.box {
		margin: 15px;
		padding: 10px 15px;
		padding-top: 5px;
		border-radius: 6px;

		.header {
			flex-direction: row;
			justify-content: space-between;

			.box-title {
				font-weight: bold;
			}

			.box-icon {
				.iconfont {
					font-size: 22px;
				}
			}
		}

		.content {
			font-size: 12px;
			flex-wrap: wrap;
			word-wrap: break-word;
			word-break: break-all;
		}

	}
</style>
